package com.js.basicpage.activity;

// Created by JS on 2021/1/23.

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.js.basicpage.R;
import com.js.basicutils.NavigationBarUtil;

public class WatchPictureActivity extends AppCompatActivity {

    private ImageView picture;
    private TextView tvCentreTitle;
    private LinearLayout headerBack;

    public static void startActivity(Context context, String imagePath, String title) {
        Intent intent = new Intent(context, WatchPictureActivity.class);
        if (imagePath != null) intent.putExtra("path", imagePath);
        if (title != null) intent.putExtra("title", title);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watch_picture);
        NavigationBarUtil.setSysNavigationTransparent(this);
        initView();
        initData();
    }

    private void initView() {
        tvCentreTitle = findViewById(R.id.centre_title);
        picture = findViewById(R.id.picture);
        headerBack = findViewById(R.id.header_back);
        headerBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initData() {
        String path = getIntent().getStringExtra("path");
        String title = getIntent().getStringExtra("title");
        if (path != null && !TextUtils.isEmpty(path)) {
            Bitmap bitmap = BitmapFactory.decodeFile(path);
            picture.setImageBitmap(bitmap);
        }
        if (title != null && !TextUtils.isEmpty(title)) {
            tvCentreTitle.setText(title);
        }
    }
}
